{% extends "cms/Base.html" %}
{% block title %}
    <title>后台用户</title>
{% endblock  %}

{% block head %}
    <script src="../../static/cms/js/cms_user.js"></script>
{% endblock %}

{% block body %}
    <div class="container-fluid center">
        <div class="row">
            <div class="col-2 offset-1">
                <div class="list-group">
                  <a href="{{url_for("cms.cms_user")}}" class="list-group-item list-group-item-action">后台用户列表</a>
                  <a href="{{url_for("cms.cms_user_add")}}" class="list-group-item list-group-item-action">新增后台用户</a>
                </div>
            </div>

            <div class="col-8">
                {% block cms_user_body %}
                    <h5 class="text-center">后台用户</h5>
                    <table class="table">
                              <thead>
                                <tr>
                                  <th scope="col">序号</th>
                                  <th scope="col">用户名</th>
                                  <th scope="col">职位</th>
                                  <th scope="col">注册日期</th>
                                  <th scope="col">邮箱</th>
                                  <th scope="col">操作</th>
                                </tr>
                              </thead>
                              <tbody>
                                {% for user in users %}
                                <tr>
                                  <th scope="row">{{ loop.index }}</th>
                                  <td>{{ user.username }}</td>
                                  <td>{{ user.role.name }}</td>
                                  <td>{{ user.join_time }}</td>
                                  <td>{{ user.email }}</td>
                                  <td>
                                      {% if user.role.id==1 %}
                                        {% if user.is_active %}
                                          <button type="button" class="btn btn-danger btn-active-cms_user" data-user-id="{{user.id}}" data-is_active="1">冻结</button>
                                        {% else %}
                                          <button type="button" class="btn btn-success btn-active-cms_user" data-user-id="{{user.id}}" data-is_active="0">激活</button>
                                        {% endif %}
                                      {% endif %}

                                  </td>
                                </tr>
                                {% endfor %}
                              </tbody>
                            </table>
                {% endblock %}
            </div>

        </div>
    </div>
{% endblock %}